<?php

/**
 * RbisRecord form base class.
 *
 * @method RbisRecord getObject() Returns the current form's model object
 *
 * @package    rbis
 * @subpackage form
 * @author     Norú Moreno, Fahmi Machda, Chandra Prasyeto
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseRbisRecordForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'             => new sfWidgetFormInputHidden(),
      'species_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('RbisSpecies'), 'add_empty' => false)),
      'station_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('RbisStation'), 'add_empty' => false)),
      'research_id'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('RbisResearch'), 'add_empty' => true)),
      'contributor_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('RbisContributor'), 'add_empty' => true)),
      'zone'           => new sfWidgetFormInputText(),
      'depth'          => new sfWidgetFormInputText(),
      'quantity'       => new sfWidgetFormInputText(),
      'created_at'     => new sfWidgetFormDateTime(),
      'updated_at'     => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'             => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'species_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('RbisSpecies'))),
      'station_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('RbisStation'))),
      'research_id'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('RbisResearch'), 'required' => false)),
      'contributor_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('RbisContributor'), 'required' => false)),
      'zone'           => new sfValidatorString(array('max_length' => 30, 'required' => false)),
      'depth'          => new sfValidatorNumber(array('required' => false)),
      'quantity'       => new sfValidatorNumber(array('required' => false)),
      'created_at'     => new sfValidatorDateTime(),
      'updated_at'     => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('rbis_record[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'RbisRecord';
  }

}
